const merge = (nums1, m, nums2, n) => {
    let arr = new Array(m + n).fill(0)
    let i = 0, j = 0, num;
    while (i < m || j < n) {
        if (i === m) {
            num = nums2[j++]
        } else if (j === n) {
            num = nums1[i++]
        } else if (nums1[i] < nums2[j]) {
            num = nums1[i++]
        } else {
            num = nums2[j++]
        }
        arr[i + j - 1] = num
    }
    console.log(arr);
    for (let k = 0; k != m + n; k++) {
        nums1[k] = arr[k]
    }
    return nums1
}
console.log(merge([1, 2, 3, 0, 0, 0], 3, [2, 5, 6], 3));